home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / include / fastcoun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-25  |  1.7 KB  |  67 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknowledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef _FastCounter_h
  13. #define _FastCounter_h
  14.  
  15. #include <bool.h>
  16. #include "Screen.h"
  17.  
  18. class CounterFont
  19. {
  20. public:
  21.     CounterFont(short Height);
  22.  
  23.     // x must be multiple of 16
  24.     void GetImages(Screen&,short x,short y);
  25.  
  26.     friend class FastCounter;
  27.     void Draw(short,long Offset); // Draw "00" to "99"; 100+x=" x", 110="  "
  28.  
  29. private:
  30.     short *Data;
  31.     short shifts;
  32.     short height;
  33. };
  34.  
  35. class FastCounter
  36. {
  37. public:
  38.     // Use given font, draw at (x,y) - x multiple of 16,
  39.     // initial counter value v, given number of digits (multiple of 2).
  40.     FastCounter(CounterFont*,int x,int y,unsigned v=0,short digits=6,short plane=0);
  41.     ~FastCounter();
  42.  
  43.     void Draw();            // Draw on current page
  44.     void Add(short);        // Increase/decrease
  45.     void Set(unsigned);
  46.     void operator ++ () {Add(1);}
  47.     void operator -- () {Add(-1);}
  48.     void operator += (short x) {Add(x);}
  49.     void operator -= (short x) {Add(-x);}
  50.     FastCounter& operator = (unsigned x) { Set(x); return *this; }
  51.     operator int();            // Convert to int
  52.     operator double();        // convert to double
  53.     void MoveTo(short x,short y,short plane=0);
  54.     void ZeroSuppression(bool on=TRUE);    // Turned on by default
  55.  
  56. private:
  57.     bool LeadingZeroes;
  58.     unsigned short Changed[2];
  59.     short Size;
  60.     long Offset;
  61.     short plane;
  62.     CounterFont *Font;
  63.     unsigned short *Digit;
  64. };
  65.  
  66. #endif
  67.